<template>
    <div class="container">
        <div class="login-wrapper">
            <div class="header">Sign up</div>
            <div class="form-wrapper">
                <div>
                    <input type="text" name="username" id="username" v-model="username" placeholder="登录账号"
                        class="input-item">
                    <input type="password" name="password" v-model="password" id="password" placeholder="登录密码"
                        class="input-item">
                    <input type="password" name="password2" v-model="password2" id="password2" placeholder="确认密码"
                        class="input-item">
                    会员注册<input type="radio" id="">
                    <input class="btn" type="submit" @click=" check()" value="注册" />
                </div>
            </div>
            <div class="msg">
                你有账户？？？ <a href='login.jsp' style="font-weight: bold;"> 去登录 </a>
            </div>
        </div>
    </div>

</template>

<script>
import axios from 'axios';
export default {
    data() {
        return {
            username: '',
            password: '',
            password2: '',
        }
    },
    methods: {
        check() {
            if (this.username == "") {
                alert("用户名不能为空！");
            }
            else if (this.password == "") {
                alert("密码不能为空！");
            }
            else if (this.password2 != this.password) {
                alert("密码输入不一致！");
            } else {
                console.log('fadsfadesf')
                axios({
                    method: 'post',
                    url: "http://localhost:8090/Goods/AddGoods",
                    params: {
                        password: this.password,
                        name: this.username,
                    }
                }).then(res => {
                    console.log(res.data);
                    if (res.data == 1) {
                        alert('添加成功')
                        this.$router.go(-1)
                    }
                }
                ).catch(error => {
                    console.log(error.response)
                })
            }
        }
    }
}
</script>

<style scoped>
* {
    padding: 0;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: .05em;
}

html {
    height: 100%;
}

body {
    height: 100%;
}

.container {
    height: 100%;
    /*background-image: linear-gradient(to right, #fbc2eb, #a6c1ee); 设置渐变色 */
    padding: 0;
    margin: 0;
    background-size: 100% 100%;
}

.login-wrapper {
    background-color: #fff;
    width: 250px;
    height: 500px;
    position: relative;
    padding: 0 50px;
    border-radius: 15px;
    left: 40%;
    top: 50%;
    margin-top: 60px;
}

.login-wrapper .header {
    font-size: 30px;
    font-weight: bold;
    text-align: center;
    line-height: 120px;
}

.login-wrapper .form-wrapper .input-item {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    border: 0;
    padding: 10px;
    border-bottom: 1px solid rgb(128, 125, 125);
    font-size: 15px;
    outline: none;
}

.login-wrapper .form-wrapper .input-item ::placeholder {
    text-transform: uppercase;
}

.login-wrapper .form-wrapper .btn {
    text-align: center;
    padding: 10px;
    margin-top: 20px;
    width: 100%;
    background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
    color: #fff;
}

.login-wrapper .msg {
    text-align: center;
    line-height: 80px;
}

.login-wrapper .msg a {
    /* 消除下划线 */
    text-decoration: none;
    text-decoration-color: unset;
    color: #a6c1ee;
}

footer {
    position: fixed;
    background: #C2BE9E;
    width: 100%;
    bottom: 0;
    left: 0;
}

footer .conter {
    border: 1px solid #C2BE9E;
    text-align: center;
}
</style>
